package com.hongye.house.controller;

import java.util.Arrays;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.hongye.house.entity.NewsImgEntity;
import com.hongye.house.service.NewsImgService;
import com.hongye.common.utils.PageUtils;
import com.hongye.common.utils.R;



/**
 * 咨询图片表
 *
 * @author gxx
 * @email hongyezhaofang.com
 * @date 2021-10-17 18:51:07
 */
@RestController
@RequestMapping("house/newsimg")
public class NewsImgController {
    @Autowired
    private NewsImgService newsImgService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = newsImgService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{id}")
    public R info(@PathVariable("id") Integer id){
		NewsImgEntity newsImg = newsImgService.getById(id);

        return R.ok().put("newsImg", newsImg);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    public R save(@RequestBody NewsImgEntity newsImg){
		newsImgService.save(newsImg);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    public R update(@RequestBody NewsImgEntity newsImg){
		newsImgService.updateById(newsImg);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    public R delete(@RequestBody Integer[] ids){
		newsImgService.removeByIds(Arrays.asList(ids));

        return R.ok();
    }

}
